package com.cal.systemcode.web;

import com.cal.systemcode.dao.SystemAreaMapper;
import com.cal.systemcode.entity.SystemAreaEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@EnableAutoConfiguration
public class SystemAreaController {

    @Autowired
    private SystemAreaMapper systemAreaMapper;
    @GetMapping("/list/level/{level}")
    public List getAreaListByLevel( @PathVariable("level") String level) {
        SystemAreaEntity systemAreaEntity = new SystemAreaEntity ();
        systemAreaEntity.setStrLevel(level);
        List<SystemAreaEntity> systemCodeEntityList = systemAreaMapper.querySystemArea(systemAreaEntity);
        return systemCodeEntityList;
    }
    @GetMapping("/list/strParent/{strParent}")
    public List getAreaListByParent(@PathVariable("strParent") String strParent) {
        SystemAreaEntity systemAreaEntity = new SystemAreaEntity ();
        systemAreaEntity.setStrParent(strParent);
        List<SystemAreaEntity> systemCodeEntityList = systemAreaMapper.querySystemArea(systemAreaEntity);
        return systemCodeEntityList;
    }

    @GetMapping("/list")
    public List getAreaList( SystemAreaEntity systemAreaEntity) {
        List<SystemAreaEntity> systemCodeEntityList = systemAreaMapper.querySystemArea(systemAreaEntity);
        return systemCodeEntityList;
    }
}